def commit():

    app = request.args[0]
    path = apath(app, r=request)

    uio = ui.ui(debug=True,verbose=True)
    try:
        r = hg.repository(ui=uio, path=path)
    except:
        r = hg.repository(ui=uio, path=path, create=True)
    form = FORM('Comment:',INPUT(_name='comment',requires=IS_NOT_EMPTY()),
                INPUT(_type='submit',_value='Commit'))
    if form.accepts(request.vars,session):
        files = listdir(apath('%s/' % app, r=request), '^ABOUT$', 0)
        files += listdir(apath('%s/' % app, r=request), '^LICENSE$', 0)
        files += listdir(apath('%s/models/' % app, r=request), '^.*\.py$', 0)        
        files += listdir(apath('%s/controllers/' % app, r=request), '^.*\.py$', 0)        
        files += listdir(apath('%s/views/' % app, r=request), '^.*\.html$', 0)        
        files += listdir(apath('%s/languages/' % app, r=request), '^.*\.py$', 0)        
        files += listdir(apath('%s/modules/' % app, r=request), '^.*\.py$', 0)        
        files += listdir(apath('%s/static/' % app, r=request), '.*', 0)        
        files = [f[len(path)+1:] for f in files]
        r.add(files)
        r.commit(text=form.vars.comment)
    else:
        files=[]
    return dict(form=form,files=TABLE(*[TR(file) for file in files]),repo=r)
